﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ServiceSecurity
{
    public static class ServiceSecurityFactory
    {
        private const string _default = "ServiceSecurity.SimpleServiceSecurity";
        public static IServiceSecurity GetServiceSecurity()
        {
            string service = ConfigurationManager.AppSettings["ServiceSecurity"] ?? _default;
            Type t = Type.GetType(service);
            if (t != null && t.GetInterfaces().Contains(typeof(IServiceSecurity)))
            {
                return (IServiceSecurity)Activator.CreateInstance(t);
            }
            return null;
        }
    }
}
